﻿using System.Collections.Generic;
using System.Diagnostics.Contracts;

namespace WyUnity.Utility.Cache
{
	[ContractClass(typeof(ILRUContract<>))]
	public interface ILRU<T>
	{
		void Remove(LinkedListNode<T> node);
		void MarkUse(LinkedListNode<T> node);

		LinkedListNode<T> AddNew(T value);
		void AutoKnockOut();
		int Count { get; }

		void Clear();
	}
	[ContractClassFor(typeof(ILRU<>))]
	abstract class ILRUContract<T>:ILRU<T>
	{
		public void Remove(LinkedListNode<T> node)
		{
			Contract.Requires(node != null);
		}

		public void MarkUse(LinkedListNode<T> node)
		{
			Contract.Requires(node != null);
		}

		public LinkedListNode<T> AddNew(T value)
		{
			return null;
		}

		public void AutoKnockOut()
		{
		}

		public int Count
		{
			get { return default(int); }
		}
		public void Clear(){}
	}
}